const topoUtil = {}

// 如果需要手动映射type和组件的关系，请在这里配置
topoUtil.viewRegisterMap = {
  triangle: 'view-triangle',
  rect: 'view-rect',
  circular: 'view-circular',
  line: 'view-line',
  webView: 'view-web-view',
  video: 'view-video',
  'line-arrow': 'view-line-arrow',
  'iot-explain': 'iot-explain',
  'iot-param': 'iot-param',
  'iot-setting': 'iot-setting',
  'iot-camera': 'iot-camera',
  'iot-device-status': 'iot-device-status',
  'iot-device-warn': 'iot-device-warn',
  dashed: 'view-dashed'
}

// 优先匹配map，否则将自动匹配
topoUtil.parseViewName = function(component) {
  let viewName = topoUtil.viewRegisterMap[component.type]
  console.log('viewName :', viewName, component.type)
  if (viewName === undefined) {
    console.info(
      `没有手动配置组件映射，将根据数据的type自动匹配，当前组件类型=${component.type}`
    )
    viewName = 'view-' + component.type
  }
  return viewName
}

export default topoUtil
